class Solution:
    def lengthOfLongestSubstring(self, s):
        """
        :type s: str
        :rtype: int
        """
        max_length = 0
        substring = []
        for i in s:
            is_in = False
            for k in range(len(substring)):
                if substring[k] == i:
                    substring.append(i)
                    substring = substring[k+1:]
                    is_in = True
                    break
            if not is_in:
                substring.append(i)
                length = len(substring)
                max_length = max(length, max_length)

        return max_length
